<?php
/**
 * common model file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2020/03/14
 * Time: 10:40
 */

namespace HiCommon\Model;

class StoreOrderRefundGoods extends Base
{

    protected $table = 'store_order_refund_goods';

    protected $guarded = [];

    //public $timestamps = false;

    /**
     * 应该被调整为日期的属性
     *
     * @var array
     */
    protected $dates = [];

    /**
     *  关联订单商品
     *
     **/
    public function order_goods()
    {
        return $this->hasOne(StoreOrderGoods::class, 'id', 'store_order_goods_id')
            ->with(['goods', 'goods_product' => function ($query) {
                $query->with(['specs', 'goods_info']);
            }]);
    }

    /**
     *  关联订单商品
     *
     **/
    public function get_order_goods()
    {
        return $this->hasOne(StoreOrderGoods::class, 'id', 'store_order_goods_id');
    }

    /**
     *  关联退单
     *
     **/
    public function order_refund()
    {
        return $this->hasOne(StoreOrderRefund::class, 'id','store_order_refund_id')
            ->select('id','apply_type','apply_state');
    }

    /**
     * 获取图片可用链接
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getImgUrlAttribute($value)
    {
        $arr_data = [
            'src' => $value,
            'full_src' => oss_full_url($value),
        ];
        return $arr_data;
    }


}